Crate glyph_brush_draw_cache
source ·Expand description
Rasterization cache for ab_glyph. Manages a updates to a texture (e.g. one stored on a GPU) drawing new glyphs, reusing & reordering as necessary.
§Example
use glyph_brush_draw_cache::DrawCache;
// build a cache with default settings
let mut draw_cache = DrawCache::builder().build();
// queue up some glyphs to store in the cache
for (font_id, glyph) in glyphs {
draw_cache.queue_glyph(font_id, glyph);
}
// process everything in the queue, rasterizing & uploading as necessary
draw_cache.cache_queued(&fonts, |rect, tex_data| update_texture(rect, tex_data))?;
// access a given glyph's texture position & pixel position for the texture quad
match draw_cache.rect_for(font_id, &glyph) {
Some((tex_coords, px_coords)) => {}
None => { /* The glyph has no outline, or wasn't queued up to be cached */ }
}
Modules§
- Re-exported ab_glyph types.
Structs§
- Dynamic rasterization draw cache.
- Builder & rebuilder for
DrawCache
. - A rectangle, with top-left corner at min, and bottom-right corner at max. Both field are in
[offset from left, offset from top]
format.
Enums§
- Returned from
DrawCache::cache_queued
. - Successful method of caching of the queue.
Type Aliases§
- (Texture coordinates, pixel coordinates)